﻿// Decompiled with JetBrains decompiler
// Type: Netick.BehaviourList
// Assembly: Netick, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 6726ECA1-C773-4CF7-8952-E81B30D93B52
// Assembly location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.dll
// XML documentation location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.xml

using System;

#nullable disable
namespace Netick;

internal class BehaviourList
{
  public INetickScript[] List;
  public int Order;
  public int Count;

  public BehaviourList(int order, int cap)
  {
    this.Order = order;
    this.List = new INetickScript[cap];
  }

  public void Add(INetickScript script)
  {
    if (script.Index != -1)
      return;
    if (this.Count >= this.List.Length)
      Array.Resize<INetickScript>(ref this.List, this.List.Length * 2);
    this.List[this.Count] = script;
    script.Index = this.Count;
    ++this.Count;
  }

  public bool Remove(INetickScript script)
  {
    if (script.Index == -1)
      return false;
    this.List[script.Index] = this.List[this.Count - 1];
    this.List[script.Index].Index = script.Index;
    this.List[this.Count - 1] = (INetickScript) null;
    --this.Count;
    script.Index = -1;
    return true;
  }

  public void Clear()
  {
    this.Count = 0;
    Array.Clear((Array) this.List, 0, this.List.Length);
  }
}
